package job

import (
	common "Monitor/common"
	sender "Monitor/sender"
)

var JobLogger = common.BLogger

type TaskReply struct {
	Name   string
	Status bool
	Error  error
	Logger *common.CommonLogger
}

func NewTaskReply(name string) (r *TaskReply) {
	r = &TaskReply{
		Name:   name,
		Logger: common.BLogger,
	}
	return
}

func (r *TaskReply) TaskErr(err error) {
	r.Logger.Error(err.Error())
}

func (r *TaskReply) TaskDone(v interface{}) {
	switch v.(type) {
	case map[string]string:
		s := sender.NewAgent()
		s.SetAgent()
		zabbix_kv := v.(map[string]string)
		for k, val := range zabbix_kv {
			s.Data = append(s.Data, s.AddData(k, val))
		}
		s.Sender(s.Data)
	}
}
